import { defineStore } from "pinia"

export const useKeepAliveStore = defineStore("pinia-keepAlive", {
    state: () => ({
        keepAliveList: []
    }),
    actions: {
        addKeepAliveName (name) {
            if (!this.keepAliveList.includes(name)) {
                this.keepAliveList.push(name)
            }
        },
        removeKeepAliveName (name) {
            this.keepAliveList = this.keepAliveList.filter(item => item !== name)
        },
        // 设置缓存列表
        setKeepAliveName (keepAliveName) {
            this.keepAliveList = keepAliveName
        }
    }
})